package com.learn.webservice.controller;

import com.learn.webservice.server.UserService;
import com.mate.cloud.core.response.BaseResponse;
import com.mate.cloud.core.web.controller.AdminBaseController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
/**
 * @description: TODO
 * @author: Administrator
 * @createTime: 2023/12/15 0015 16:46
 * @version: 1.0
 */
@RestController
@RequestMapping("/user")
public class UserController extends AdminBaseController {


    @RequestMapping("/load")
    public BaseResponse load() {
        // 1、接口地址
        String address = "http://localhost:8801/webservice/api?wsdl";
        // 2、代理工厂
        JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
        // 3、设置代理地址
        jaxWsProxyFactoryBean.setAddress(address);
        // 4、设置接口类型
        jaxWsProxyFactoryBean.setServiceClass(UserService.class);
        // 5、创建一个代理接口实现
        UserService userService =(UserService) jaxWsProxyFactoryBean.create();
        // 6、调用代理接口的方法调用并返回结果
        String emrService = userService.emrService("webService");
        return successBodyResponse(emrService);

    }
}
